package com.mryang.ladder;

import com.sun.org.apache.xpath.internal.objects.XString;

import java.util.Scanner;

/**
 * @ClassName L1_016
 * @Description TODO 查验身份证
 *                   有问题输出该身份证号，都没问题则输出 All passed
 * @Author Genius
 * @Date 2021/1/26 15:05
 */
public class L1_016 {
    public static void main(String[] args) {
        Scanner scr = new Scanner(System.in);
        int number = scr.nextInt();
        int sum = 0,count=0;
        // 权重分配
        int[] weightDistribution = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
        char[] x = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};

        // 身份证号的输入
        String[] identificationNumber = new String[number];
        for (int i = 0; i < number; i++) {
            identificationNumber[i] = scr.next();
        }

        // 判断
        for(int i = 0;i < number;i++) {
            for (int j = 0; j < 17; j++) {
                sum = sum + Integer.parseInt(identificationNumber[i].charAt(j)+"") * weightDistribution[j];
            }
            System.out.println(sum);
            System.out.println(sum%11);

            switch(sum%11) {
                case 0: {
                    if (identificationNumber[i].charAt(17) == '1')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 1: {
                    if (identificationNumber[i].charAt(17) == '0')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 2: {
                    if (identificationNumber[i].charAt(17) == 'x')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 3: {
                    if (identificationNumber[i].charAt(17) == '9')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 4: {
                    if (identificationNumber[i].charAt(17) == '8')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 5: {
                    if (identificationNumber[i].charAt(17) == '7')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 6:{
                    if (identificationNumber[i].charAt(17) == '6')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 7: {
                    if (identificationNumber[i].charAt(17) == '5')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 8: {
                    if (identificationNumber[i].charAt(17) == '4')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 9: {
                    if (identificationNumber[i].charAt(17) == '3')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
                case 10: {
                    if (identificationNumber[i].charAt(17) == '2')
                        count++;
                    else
                        System.out.println(identificationNumber[i]);
                    break;
                }
            }
            if(count == number) {
                System.out.println("All passed");
            }
        }

    }
}
